package com.arithmetic.firstFirst;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class FisrtFistAction {
 static BufferedReader sc = FirstTools.reader();
    /**
     *编写一个程序,如果double类型的变量X和y都都位于0和1之间则为true,否则为false
     */
    public static boolean ifZeroAndOne(){
        System.out.println("please input something,get us kowon if zeroAnd One");
        boolean flag = false;
        List<Double> list = new ArrayList<>();
        try {
            while (true){
                System.out.println("请输入double类型的值,如果推出,请输入over");
            String scRead = sc.readLine();
            if(scRead.equals("over")&&!scRead.isEmpty()){
                System.out.println("输入退出");
                break;

            }else{
                Double d1 = Double.valueOf(scRead);
                list.add(d1);
            }
            }
            for(int i=0;i<list.size();i++){
                if(list.get(i)>0&&list.get(i)<1){
                    flag = true;
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(flag);
        return flag;
    }
    /**
     * @Description 编写一个程序,从命令行得到三个整数参数.如果他们都相等则为eaual,如何
     * 不等则为not equerl
     */
    public static String threeParamIfEqual(){
        List<Integer> list = new ArrayList<>();
        String flag = "equal";
        int b = 0;
        System.out.println("请输入至少两位数字,所有数字输入完成后,请输入over,完成计算:");
        while(true){
            String scResult = null;
            try {
                scResult = sc.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (scResult.equals("over")) {
                System.out.println("输入结束,下面显示结果:"+"\n");
                System.out.println(list+"\n");
                break;
            }else{
                try {
                    list.add(Integer.valueOf(sc.readLine()));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                System.out.println(list);
                    continue;
                }
        }
        for(int i=0;i<list.size();i++){
            if(b==list.size()-1){
                break;
            }
            System.out.println("==>"+i);
            b++;
            if(list.get(i)!=list.get(b)){
                flag = "not equal";
                break;
            }
        }
        System.out.println("<<"+b);
        System.out.println(flag);
        return flag;
    }
}
